/**
 * 列表初始化
 */
var AllUserPar = {
    id: "AllUserTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
AllUserPar.initColumn = function () {
    return [
        {title:'选择项',field: 'selectItem', radio: true},
        {title: '分销ID', field: 'userId', visible: true, align: 'center', valign: 'middle'},
        {title: '昵称', field: 'orderNo', visible: true, align: 'center', valign: 'middle'},
        {title: '用户类型', field: 'orderType', visible: true, align: 'center', valign: 'middle'},
        {title: '提交日期', field: 'settlementAt', visible: true, align: 'center', valign: 'middle'},
        {title:"操作",field:'Button',events:operateEvents,formatter:AllUserPar.AddFunction}
    ];
};

AllUserPar.AddFunction = function(value,row,index){
    return [
            '<button id="unConfineMember" type="button" class="btn btn-primary">修改</button>&nbsp;'+
            '<button id="unConfineMember" type="button" class="btn btn-primary">查看上级</button>'
        ].join("");
}

window.operateEvents = {
    'click #confineMember':function (e,value,row,index) {
        DisMemberInfo.confineMembers(1,row['disUserId']);

    },
    'click #unConfineMember':function (e,value,row,index) {
        DisMemberInfo.confineMembers(0,row['disUserId']);

    },
}

/**
 * 检查是否选中
 */
AllUserPar.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        AllUserPar.seItem = selected[0];
        return true;
    }
};

/**
 * 查询列表
 */
AllUserPar.search = function () {
    //带参查询
    AllUserPar.table.refresh({query: AllUserPar.formParams()});
};

//表单参数
AllUserPar.formParams = function() {
    var queryData = {};
    queryData['id'] = $("#id").val();
    queryData['userId'] = $("#userId").val();
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    return queryData;
}

//在整个页面加载的时候
$(function () {
    //获取列表数据
    var defaultColunms = AllUserPar.initColumn();
    var table = new BSTable(AllUserPar.id, "/alluser/list", defaultColunms);
    table.setPaginationType("server");
    table.setQueryParams(AllUserPar.formParams());
    AllUserPar.table = table.init();
});
